import { plainToClass, Type } from "class-transformer";
import { ArrayMinSize, IsNotEmpty, validate } from "class-validator";
import { Date } from "mongoose";
import { BaseClass } from "./BaseClass";

export class Content extends BaseClass{
    public title: string = '';

    @IsNotEmpty({message: "文章类型不能为空"})
    @Type(() => String)
    public class!: string;

    @IsNotEmpty({message: "文章内容不能为空"})
    public data!: string;

    @IsNotEmpty({message: "发表时间不能为空"})
    public time!: string;

    @IsNotEmpty({message: "作者不能为空"})
    public author!: string;

    @IsNotEmpty({message: "内容简述不能为空"})
    public description!: string;

    public comment?: string[] = [];

    public like?: number = 1;

    public purpose?: string;

    public static transformerThis(m: {}) {
        return super.plainClass(Content, m);
    }
}
export class Message extends BaseClass{
    @IsNotEmpty({message: "文章类型不能为空"})
    @Type(() => String)
    public text!: string;

    @IsNotEmpty({message: "发表时间不能为空"})
    public time?: Date;

    public static transformerThis(m: {}) {
        return super.plainClass(Message, m);
    }
}

